
<?php

if($this->Session->read('Auth.User.username')!=''){
	$name = $this->Session->read('Auth.User.username');

//print_r($order);
	?>

	<div class="container" padding="50px">

		<table cellpadding="0" cellspacing="0">
			<tr>
				<td><h3>Incomplete Orders</h3></td>
			</tr>
			<tr>
				<td>
					<?php if(!empty($order)){?>
					<table id="data" class="dashTable dashTable-striped" cellpadding="0" cellspacing="0">
						<tr>
							<th>Order Id</th>
							<th>Supplier</th>
							<th>Date Created</th>
							<th>Days Counting</th>
							<th>Actions</th>
						</tr>
						<?php foreach ($order as $a): ?>
							<tr>
								<td><?php echo h($a['Orders']['id']); ?></td>
								<td><?php echo $this->Html->link($a['Suppliers']['supplierName'], array('controller' => 'suppliers', 'action' => 'view', $a['Suppliers']['id'])); ?></td>
								<td><?php echo date('d/m/Y', strtotime($a['Orders']['created'])); ?></td>
								<td>
									<?php 
									$now = date('Y-m-d'); $now = new DateTime($now);
									$created = $a['Orders']['created']; $created = new DateTime($created);
									$interval = $now->diff($created);
									$date = $interval->format('%a');
									echo $date.' days';
									?>
								</td>
								<td class="actions">
									<?php echo $this->Html->link(__('View Order'), array('controller' => 'orders','action' => 'view', $a['Orders']['id'])); ?>&nbsp;&nbsp;
									<?php echo $this->Html->link(__('Receive Order'), array('controller' => 'deliveries','action' => 'delivery', $a['Orders']['id'])); ?>		
								</td>
							</tr>
						<?php endforeach; ?>
					</table>
					<?php } else {?>
					All orders are currently completed.
					<?php }?>
				</td>
			</tr>
		</table>
	</div>





	<?php
}
else{?>
<fieldset><h2>Please log in.</h2></fieldset>
<?php
}
?>
